# utils作为工具包，放置相关文件

from flask import jsonify
# 定义http状态码

class HttpCode(object):
    ok=200
    unautherror = 401
    paramserrror = 400
    servererror = 500


def restful_result(code,message,data):
    return jsonify({"code":code,"massage":message,"data":data or {}})

def succss(message="",data=None):
    return restful_result(code=HttpCode.ok,message=message,data=data)

def unanth_error(message=""):
    return restful_result(code=HttpCode.unautherror,message=message,data=None)

def param_error(message=""):
    return restful_result(code=HttpCode.paramserrror,message=message,data=None)

def server_error(message=""):
    return restful_result(code=HttpCode.servererror,message=message or '服务器内部错误',data=None)
